﻿using System;

namespace HW0310_4
{
    
    abstract class Figure
    {
        public abstract double getArea();
        public abstract bool evaluate();
    }
    class Rectangle : Figure
    {
        public double ledge;
        public double sedge;
        public double lEdge
        {
            get
            {
                return ledge; // still needs to do this
            }
            set
            {
                ledge = value;
            }
        }
        public double sEdge
        {
            get
            {
                return sedge;
            }
            set
            {
                sedge = value;
            }
        }
        public override double getArea()
        {
            return lEdge * sEdge;
        }
        public override bool evaluate()
        {
            if (lEdge >= 0 && sEdge >= 0 && lEdge >= sEdge)
                return true;
            else
                return false;
        }
    }
    class Square : Figure
    {
        public double edge;
        public double Edge
        {
            get
            {
                return edge;
            }
            set
            {
                edge = value;
            }
        }
        public override double getArea()
        {
            return Edge * Edge;
        }
        public override bool evaluate()
        {
            if (Edge >= 0)
                return true;
            else
                return false;
        }
    }
    class Triangle : Figure
    {
        public double edge1, edge2, edge3;
        public double Edge1
        {
            get
            {
                return edge1;
            }
            set
            {
                edge1 = value;
            }
        }
        public double Edge2
        {
            get
            {
                return edge2;
            }
            set
            {
                edge2 = value;
            }
        }
        public double Edge3
        {
            get
            {
                return edge3;
            }
            set
            {
                edge3 = value;
            }
        }
        public override double getArea()
        {
            double p = (Edge1 + Edge2 + Edge3) / 2;
            return Math.Sqrt(p * (p - Edge1) * (p - Edge2) * (p - Edge3));
        }
        public override bool evaluate()
        {
            if ((Edge1 >= 0 && Edge2 >= 0 && Edge3 >= 0) && (Edge1 + Edge2 > Edge3) && (Edge2 + Edge3 > Edge1) && (Edge1 + Edge3 > Edge2))
                return true;
            else
                return false;
        }
    }
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Create your own rectangle...");
            Rectangle rectangle1 = new Rectangle();
            Console.Write("Enter the length of the long edge of your rectangle: ");
            rectangle1.lEdge = double.Parse(Console.ReadLine());
            Console.Write("Enter the length of the short edge of your rectangle: ");
            rectangle1.sEdge = double.Parse(Console.ReadLine());
            Console.WriteLine("Is the rectangle legitimate? : " + rectangle1.evaluate());
            if (rectangle1.evaluate())
                Console.WriteLine("The area of your rectangle: " + rectangle1.getArea());
            Console.WriteLine();
            Console.WriteLine("Create your own square...");
            Square square1 = new Square();
            Console.Write("Enter the length of edge of your edge: ");
            square1.Edge = double.Parse(Console.ReadLine());
            Console.WriteLine("Is the square legitimate? : " + square1.evaluate());
            if (square1.evaluate())
                Console.WriteLine("The area of your square: " + square1.getArea());
            Console.WriteLine();
            Console.WriteLine("Create your own triangle...");
            Triangle triangle1 = new Triangle();
            Console.Write("Enter the length of the first edge of your triangle: ");
            triangle1.Edge1 = double.Parse(Console.ReadLine());
            Console.Write("Enter the length of the second edge of your triangle: ");
            triangle1.Edge2 = double.Parse(Console.ReadLine());
            Console.Write("Enter the length of the third edge of your triangle: ");
            triangle1.Edge3 = double.Parse(Console.ReadLine());
            Console.WriteLine("Is the triangle legitimate? : " + triangle1.evaluate());
            if (triangle1.evaluate())
                Console.WriteLine("The area of your rectangle: " + triangle1.getArea());
        }
    }
}